package org.hashdb.client.net.bio.send;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hashdb.client.net.bio.MessageType;
import org.hashdb.client.net.bio.msg.ClientMessage;
import org.jetbrains.annotations.NotNull;

/**
 * Date: 2023/12/1 3:08
 *
 * @author huanyuMake-pecdle
 * @version 0.0.1
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class AuthenticationMessage extends ClientMessage {
    // 下面的属性可以用来验证链接合法性
    private PasswordAuth passwordAuth;

    @Override
    public MessageType getType() {
        return MessageType.AUTH;
    }

    public record PasswordAuth(String username, String password) {
    }

    public static @NotNull AuthenticationMessage usePasswordAuth(String username, String password) {
        var message = new AuthenticationMessage();
        message.setPasswordAuth(new PasswordAuth(username, password));
        return message;
    }
}
